//
//  PopupWebView.m
//  quxiangtao
//
//  Created by HHuajiang on 2018/11/21.
//  Copyright © 2018 shanhaijin. All rights reserved.
//

#import "PopupWebView.h"

@implementation PopupWebView
- (instancetype)init {
    
    if (self == [super init]) {
        
        UIView *bgvvv = [[UIView alloc] init];
        bgvvv.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
        [self addSubview:bgvvv];
        [bgvvv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(200, 30));
        }];
        
        UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"popopop.jpg"]];
        [bgvvv addSubview:image];
        [image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.centerY.equalTo(self.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(25, 25));
        }];
        
        self.myLabel = [[UILabel alloc] init];
        [bgvvv addSubview:self.myLabel];
        [self.myLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(image.mas_right).offset(5);
            make.right.mas_equalTo(-10);
            make.top.bottom.mas_equalTo(0);
        }];
        
        MKViewBorderRadius(bgvvv, 10, 0, [UIColor blackColor]);
    }
    return self;
}

- (void)loadWithHtml:(NSString *)html {
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    self.myLabel.attributedText = attrStr;
    self.myLabel.textAlignment = NSTextAlignmentCenter;
}

@end
